<template>
  <div>
      <div style="float:right">
       <el-button type="primary" @click="reviewBatch('批量审核',1)">批量审核</el-button>
                    <el-button type="primary" @click="reviewBatch('批量驳回',-1)">批量驳回</el-button>
                    <el-button type="primary"   @click="fanhui()">返回</el-button>
    </div>
      <el-table
                ref="tableRef"
                style="width: 100%;margin-top:20px"
                :data="dataList"
                border
                v-loading="dataListLoading">
                <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
                <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
                <el-table-column
                    prop="gzmc"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="工作名称">
                </el-table-column>
                <el-table-column
                    prop="cyrname"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="姓名">
                </el-table-column>
                <el-table-column
                    prop="cyrdepname"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="职务">
                </el-table-column>
                <el-table-column
                    prop="pfrname"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="打分人">
                </el-table-column>
                <el-table-column
                    prop="shrname"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="审核人">
                </el-table-column>
                <el-table-column
                    prop="enddate"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="结束时间">
                </el-table-column>
                 <el-table-column
                    prop="shstate"
                    header-align="center"
                    align="center"
                    min-width="120"
                    label="状态">
                     <template slot-scope="scope">
                         <span v-if="scope.row.shstate == '0'">未审核</span>
                        <span v-if="scope.row.shstate == '1'">已审核</span>
                        <span style="color:#ff3300" v-if="scope.row.shstate == '-1'">已驳回</span>
                     </template>
                </el-table-column>
                <el-table-column
                    header-align="center"
                    align="center"
                    fixed="right"
                    min-width="150"
                    label="操作">
                    <template slot-scope="scope">
                    <el-button type="primary" plain size="small" :disabled="scope.row.shstate==1" @click="shenhe(scope.row)"
                               >审核
                    </el-button>
                    <el-button type="primary" plain size="small" :disabled="scope.row.shstate==-1"   @click="boHui(scope.row)"
                               >驳回
                    </el-button>
                    </template>
                </el-table-column>
            </el-table>
  </div>
</template>

<script>
import {getListpfcyr,updateCyshById,updateZxgzcysh} from '@/api/hetongrenwu/zhuanxianggongzuo/zxgzchuangjian'
export default {
    name:"zxsh-form",
    props: {
      zxshcyid:Number

  },
    data(){
        return{
            dataList:[],
            dataListLoading:false
        }
    },
    methods:{
        boHui(obj){
            // this.$emit('zxshC','驳回');
            updateCyshById(obj.id,-1).then(response => {
                    this.$message({
                        type: 'success',
                        message: '驳回成功!'
                    });
                    this.$nextTick(() => {
                         this.getDataList();
                     })
         })
        },
         fanhui(){
                this.$emit('zxshC','返回');
        },
        reviewBatch(msg,states){
             const rows = this.$refs.tableRef.selection;

             var params={
                 rows:rows,
                 state:states
             }
              //console.log(JSON.stringify(params)+"==rows")
            if(rows.length > 0){
            this.$confirm('是否要'+msg+'?','提示' ,{
                    confirmButtonText: '是',
                    cancelButtonText: '否',
                    type: 'warning'
                }).then(() => {
                updateZxgzcysh(params).then(response => {
                        this.$message({
                            type: 'success',
                            message: '操作成功!'
                        });
                        this.$nextTick(() => {
                            this.getDataList();
                        })
                })
                }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消操作'
                });
                });
            }else{
                this.$message({
                type: 'info',
                message: '请选择'+msg+'数据!'
                });
                }

        },
        getDataList() {
        this.dataListLoading = true;
         var params={
                 zxshcyid:this.zxshcyid
             }
            //console.log(JSON.stringify(params))
        getListpfcyr(params).then(response => {
            this.dataList = response.data.data
           //console.log(this.dataList)
        })
        this.dataListLoading = false
        },
        getqueryDataList(objdata){
          var params={
            zxshcyid:this.zxshcyid,
            gzmc:objdata.workname,
            cyrname:objdata.cyryname,
            cyrydepartname:objdata.cyrydepartname,
            endate:objdata.jsdate
          }
          getListpfcyr(params).then(response => {
            this.dataList = response.data.data
           //console.log(this.dataList)
          })
        },
        shenhe(obj){
         updateCyshById(obj.id,1).then(response => {
                    this.$message({
                        type: 'success',
                        message: '审核成功!'
                    });
                    this.$nextTick(() => {
                         this.getDataList();
                     })
        })

        }
    }
}
</script>

<style>

</style>
